
from django.db import models
from datetime import date
from django.urls import reverse

class Picture(models.Model):
    title = models.CharField('标题', max_length=100, blank=True, default='')
    image = models.ImageField('图片', upload_to='mypictures', blank=True)
    date = models.DateField('日期', default=date)

    def __str__(self):
        return self.title

    # 对于django使用通用视图

    def get_absolute_url(self):
        return reverse('pic_upload:pic_detail', args=[str(self.id)])


